package com.bj.dz.service.impl;

import com.bj.dz.entity.WaterfactorypoolDataformat;
import com.bj.dz.mapper.WaterfactorypoolDataformatMapper;
import com.bj.dz.service.WaterfactorypoolDataformatService;
import com.bj.dz.util.Constants;
import com.bj.dz.util.EmptyUtils;
import com.bj.dz.util.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class WaterfactorypoolDataformatServiceImpl implements WaterfactorypoolDataformatService {

    @Resource
    private WaterfactorypoolDataformatMapper waterfactorypoolDataformatMapper;

    public WaterfactorypoolDataformat getWaterfactorypoolDataformatById(Integer id){
        return waterfactorypoolDataformatMapper.getWaterfactorypoolDataformatById(id);
    }

    public List<WaterfactorypoolDataformat>	getWaterfactorypoolDataformatListByMap(Map<String,Object> param){
        return waterfactorypoolDataformatMapper.getWaterfactorypoolDataformatListByMap(param);
    }

    public Integer getWaterfactorypoolDataformatCountByMap(Map<String,Object> param){
        return waterfactorypoolDataformatMapper.getWaterfactorypoolDataformatCountByMap(param);
    }

    @Transactional
    public boolean addWaterfactorypoolDataformat(WaterfactorypoolDataformat waterfactorypoolDataformat){
            return waterfactorypoolDataformatMapper.insertWaterfactorypoolDataformat(waterfactorypoolDataformat)>0?true:false;
    }

    @Transactional
    public boolean modifyWaterfactorypoolDataformat(WaterfactorypoolDataformat waterfactorypoolDataformat){
        return waterfactorypoolDataformatMapper.updateWaterfactorypoolDataformat(waterfactorypoolDataformat)>0?true:false;
    }

    @Transactional
    public boolean deleteWaterfactorypoolDataformatById(Integer id){
        return waterfactorypoolDataformatMapper.deleteWaterfactorypoolDataformatById(id)>0?true:false;
    }

    public Page<WaterfactorypoolDataformat> queryWaterfactorypoolDataformatPageByMap(Map<String,Object> param, Integer pageNo, Integer pageSize){
        Integer total = waterfactorypoolDataformatMapper.getWaterfactorypoolDataformatCountByMap(param);
        pageNo = EmptyUtils.isEmpty(pageNo) ? Constants.DEFAULT_PAGE_NO : pageNo;
        pageSize = EmptyUtils.isEmpty(pageSize) ? Constants.DEFAULT_PAGE_SIZE : pageSize;
        Page page = new Page(pageNo, pageSize, total);
        param.put("beginPos", page.getBeginPos());
        param.put("pageSize", page.getPageSize());
        List<WaterfactorypoolDataformat> waterfactorypoolDataformatList = waterfactorypoolDataformatMapper.getWaterfactorypoolDataformatListByMap(param);
        page.setRows(waterfactorypoolDataformatList);
        return page;
    }

}
